<?php
/**
 * The loop that displays posts.
 *
 * The loop displays the posts and the post content. See
 * http://codex.wordpress.org/The_Loop to understand it and
 * http://codex.wordpress.org/Template_Tags to understand
 * the tags used in it.
 *
 * This can be overridden in child themes with loop.php or
 * loop-template.php, where 'template' is the loop context
 * requested by a template. For example, loop-index.php would
 * be used if it exists and we ask for the loop with:
 * <code>get_template_part( 'loop', 'index' );</code>
 *
 * @package WordPress
 * @subpackage Twenty_Ten
 * @since Twenty Ten 1.0
 */
?>

<?php /* Display navigation to next/previous pages when applicable */ ?>

<?php /* If there are no posts to display, such as an empty archive page */ ?>
<?php if ( ! have_posts() ) : ?>
	<div id="post-0" class="post error404 not-found">
		<h1 class="entry-title"><?php _e( 'Not Found', 'twentyten' ); ?></h1>
		<div class="entry-content">
			<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyten' ); ?></p>
			<?php get_search_form(); ?>
		</div><!-- .entry-content -->
	</div><!-- #post-0 -->
<?php endif; ?>

<?php
	/* Start the Loop.
	 *
	 * In Twenty Ten we use the same loop in multiple contexts.
	 * It is broken into three main parts: when we're displaying
	 * posts that are in the gallery category, when we're displaying
	 * posts in the asides category, and finally all other posts.
	 *
	 * Additionally, we sometimes check for whether we are on an
	 * archive page, a search page, etc., allowing for small differences
	 * in the loop on each template without actually duplicating
	 * the rest of the loop that is shared.
	 *
	 * Without further ado, the loop:
	 */ 
	 $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
	 ?>
<?php $the_query = new WP_Query( array('post_type'=>'video','paged' => $page) );	 ?>
		<div class="content_text_holder"><div class="content_title">Videos</div></div>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
		<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
			<div class="content_text_holder">
				<div class="content_image left">
					<?php 
						if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
						  echo get_the_post_thumbnail($post->ID, array(222,222) );
						} 
					?>
				</div>
				<div class="content_text right">
					<div class="content_title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></div>
					<div class="content_tile_sub italic">
						<div> Posted on <?php echo get_the_date();?></div>
					</div>
					<div>
					 <p><?php echo excerpt(50); ?></p>
					</div>
				</div>
				<div class="clear"></div>
			</div>
			<div class="content_bar">
				<div class="left"><?php wp_share_this(get_permalink($post->ID))?></div>
				<div class="right"> 
					<span class="comments-link">
						<img src="<?php bloginfo('template_url');?>/images/comments_icon.png" alt="comments" class="comments_icon" />
						<?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?>
					</span>					
				</div>
				<div class="clear"></div>
			</div>
			
		</div><!-- #post-## -->
<?php endwhile; // End the loop. Whew. ?>
<?php 
$total_pages = $the_query->found_posts; 
$max_pages = $the_query->max_num_pages; 
?>
<?php if (  $the_query->max_num_pages > 1 ) : ?>
				<div id="nav-below" class="navigation">
					<?php if(function_exists('wp_paginate')) {
						wp_paginate("page=$page&range=3&anchor=1&gap=3&pages=$max_pages");
					} ?>
				</div><!-- #nav-below -->
<?php endif; ?>